package com.jbinfo.qingcaowan.common;

import java.io.Serializable;

public class JSONResult implements Serializable {
	
	private static final long serialVersionUID = -4114045990410261418L;
	private Object resultBean;	//返回实体
	private String resultCode;	//返回结果编码
	private String errorMessage;	//返回结果信息
	private String errorStackTrack;	//返回结果的堆栈信息

	
	public JSONResult() {
	}
	public JSONResult(Object resultBean,String resultCode,String errorMessage,String errorStackTrack) {
		this.resultBean = resultBean;
		this.resultCode = resultCode;
		this.errorMessage = errorMessage;
		this.errorStackTrack = errorStackTrack;
	}
	
	/** 
	* @Description:判断返回结果是否是成功
	* @author lizhenwei  
	* @date 2016-07-05 下午11:19:47 
	* @return  
	*/ 
	public static boolean isSuccess(JSONResult result){
		return result != null && ResultCode.SUCCESS.equals(result.getResultCode());
	}
	
	/**
	 * @Description: 属性 resultBean 的get方法 
	 * @return resultBean
	 */
	@SuppressWarnings("unchecked")
	public <T> T getResultBean() {
		return (T)resultBean;
	}
	/**
	 * @Description: 属性 resultBean 的set方法 
	 * @param resultBean 
	 */
	public void setResultBean(Object resultBean) {
		this.resultBean = resultBean;
	}
	/**
	 * @Description: 属性 resultCode 的get方法 
	 * @return resultCode
	 */
	public String getResultCode() {
		return resultCode;
	}
	/**
	 * @Description: 属性 resultCode 的set方法 
	 * @param resultCode 
	 */
	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}
	/**
	 * @Description: 属性 errorMessage 的get方法 
	 * @return errorMessage
	 */
	public String getErrorMessage() {
		return errorMessage;
	}
	/**
	 * @Description: 属性 errorMessage 的set方法 
	 * @param errorMessage 
	 */
	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}
	/**
	 * @Description: 属性 errorStackTrack 的get方法 
	 * @return errorStackTrack
	 */
	public String getErrorStackTrack() {
		return errorStackTrack;
	}
	/**
	 * @Description: 属性 errorStackTrack 的set方法 
	 * @param errorStackTrack 
	 */
	public void setErrorStackTrack(String errorStackTrack) {
		this.errorStackTrack = errorStackTrack;
	}
	/**
	* <p>Description: </p> 
	* @author lizhenwei   
	* @date 2016-7-05 下午11:16:59 
	* @return 
	* @see java.lang.Object#toString() 
	*/ 
	@Override
	public String toString() {
		return "JSONResult [resultBean=" + resultBean + ", resultCode="
				+ resultCode + ", errorMessage=" + errorMessage
				+ ", errorStackTrack=" + errorStackTrack + "]";
	}
	
}
